// 806. 写字符串需要的行数
/**
 * @param {number[]} widths
 * @param {string} s
 * @return {number[]}
 */
const MAX_WIDTH = 100
var numberOfLines = function (widths, s) {
    let lines = 1, width = 0
    for (let i = 0; i < s.length; i++) {
        const need = widths[s[i].charCodeAt() - 'a'.charCodeAt()]
        width += need
        if (width > MAX_WIDTH) {
            lines++
            width = need
        }
    }
    return [lines, width]
};
const result = numberOfLines([7, 5, 4, 7, 10, 7, 9, 4, 8, 9, 6, 5, 4, 2, 3, 10, 9, 9, 3, 7, 5, 2, 9, 4, 8, 9],
    "zlrovckbgjqofmdzqetflraziyvkvcxzahzuuveypqxmjbwrjvmpdxjuhqyktuwjvmbeswxuznumazgxvitdrzxmqzhaaudztgie")
console.log('result :>>', result);